import java.util.concurrent.TimeUnit;

public class Demo_904 {
    public static void main(String[] args) throws InterruptedException{
        //初始化自定义的线程池
        MyThreadPool threadPool = new MyThreadPool(3);

        //通过循环向线程池中提交任务
        for (int i=0;i<10;i++){
            int taskId = i+1;
            threadPool.submit(()->{
                System.out.println("执行任务: "+taskId+","+Thread.currentThread().getName());
            });

            if (taskId %2 ==0){
                TimeUnit.SECONDS.sleep(1);
            }
        }
    }
}
